package GormModel

import (
	"database/sql"
	"time"
)

// TzUserAddr 用户地址表
type TzUserAddr struct {
	AddrID     uint64    `gorm:"primaryKey;autoIncrement;comment:ID"`
	UserID     string    `gorm:"type:varchar(36);not null;comment:用户 ID"`
	Receiver   string    `gorm:"type:varchar(50);comment:收货人"`
	ProvinceID uint64    `gorm:"comment:省 ID"`
	Province   string    `gorm:"type:varchar(100);comment:省"`
	City       string    `gorm:"type:varchar(20);comment:城市"`
	CityID     uint64    `gorm:"comment:城市 ID"`
	Area       string    `gorm:"type:varchar(20);comment:区"`
	AreaID     uint64    `gorm:"comment:区 ID"`
	PostCode   string    `gorm:"type:varchar(15);comment:邮编"`
	Addr       string    `gorm:"type:varchar(1000);comment:地址"`
	Mobile     string    `gorm:"type:varchar(20);comment:手机"`
	Status     int       `gorm:"not null;comment:状态,1 正常，0 无效"`
	CommonAddr int       `gorm:"not null;default:0;comment:是否默认地址 1 是"`
	CreateTime time.Time `gorm:"not null;comment:建立时间"`
	Version    int       `gorm:"not null;default:0;comment:版本号"`
	UpdateTime time.Time `gorm:"not null;comment:更新时间"`
}

// TableName 实现gorm的TableName方法，指定该实体类对应的数据库表名
func (TzUserAddr) TableName() string {
	return "tz_user_addr"
}

// TzOrder 订单表
type TzOrder struct {
	OrderID       uint64           `gorm:"column:order_id;primaryKey;autoIncrement;comment:订单ID" json:"orderId"`
	ShopID        *uint64          `gorm:"column:shop_id;comment:店铺id" json:"shopId"` // 允许 NULL 的字段用指针
	ProdName      string           `gorm:"column:prod_name;type:varchar(1000);not null;default:'';comment:产品名称,多个产品将会以逗号隔开" json:"prodName"`
	UserID        string           `gorm:"column:user_id;type:varchar(36);not null;comment:订购用户ID" json:"userId"`
	OrderNumber   string           `gorm:"column:order_number;type:varchar(50);not null;uniqueIndex;comment:订购流水号" json:"orderNumber"`
	Total         float64          `gorm:"column:total;type:decimal(15,2);not null;default:0.00;comment:总值" json:"total"`
	ActualTotal   *float64         `gorm:"column:actual_total;type:decimal(15,2);comment:实际总值" json:"actualTotal"` // 允许 NULL 的字段用指针
	PayType       *int             `gorm:"column:pay_type;comment:支付方式 0 手动代付 1 微信支付 2 支付宝" json:"payType"`
	Remarks       *string          `gorm:"column:remarks;type:varchar(1024);comment:订单备注" json:"remarks"` // 允许 NULL 的字段用指针
	Status        int              `gorm:"column:status;not null;default:0;comment:订单状态 1:待付款 2:待发货 3:待收货 4:待评价 5:成功 6:失败"`
	DvyType       *string          `gorm:"column:dvy_type;type:varchar(10);comment:配送类型" json:"dvyType"`
	DvyID         *uint64          `gorm:"column:dvy_id;comment:配送方式ID" json:"dvyId"`
	DvyFlowID     string           `gorm:"column:dvy_flow_id;type:varchar(100);default:'';comment:物流单号" json:"dvyFlowId"`
	FreightAmount float64          `gorm:"column:freight_amount;type:decimal(15,2);default:0.00;comment:订单运费" json:"freightAmount"`
	AddrOrderID   *uint64          `gorm:"column:addr_order_id;comment:用户订单地址Id" json:"addrOrderId"`
	ProductNums   *int             `gorm:"column:product_nums;comment:订单商品总数" json:"productNums"`
	CreateTime    time.Time        `gorm:"column:create_time;not null;comment:订购时间" json:"createTime"` // NOT NULL 字段用 time.Time
	UpdateTime    *time.Time       `gorm:"column:update_time;comment:订单更新时间" json:"updateTime"`        // 允许 NULL 的字段用指针
	PayTime       *time.Time       `gorm:"column:pay_time;comment:付款时间" json:"payTime"`
	DvyTime       *time.Time       `gorm:"column:dvy_time;comment:发货时间" json:"dvyTime"`
	FinallyTime   *time.Time       `gorm:"column:finally_time;comment:完成时间" json:"finallyTime"`
	CancelTime    *time.Time       `gorm:"column:cancel_time;comment:取消时间" json:"cancelTime"`
	IsPayed       *int             `gorm:"column:is_payed;comment:是否已经支付，1：已经支付过，0：没有支付过" json:"isPayed"` // Java 中是 Integer
	DeleteStatus  int              `gorm:"column:delete_status;default:0;comment:用户订单删除状态，0：没有删除， 1：回收站， 2：永久删除" json:"deleteStatus"`
	RefundSts     int              `gorm:"column:refund_sts;default:0;comment:0:默认,1:在处理,2:处理完成" json:"refundSts"`
	ReduceAmount  *float64         `gorm:"column:reduce_amount;type:decimal(15,2);comment:优惠总额" json:"reduceAmount"`
	OrderType     *int8            `gorm:"column:order_type;type:tinyint;comment:订单类型" json:"orderType"` // SQL 是 tinyint
	CloseType     *int8            `gorm:"column:close_type;type:tinyint;comment:订单关闭原因 1-超时未支付 2-退款关闭 4-买家取消 15-已通过货到付款交易" json:"closeType"`
	ShopName      string           `gorm:"-" json:"shopName"`                                                  // 忽略数据库字段
	OrderItems    []TzOrderItem    `gorm:"foreignKey:OrderNumber;references:OrderNumber" json:"orderItems"`    // 一对多关系
	UserAddrOrder *TzUserAddrOrder `gorm:"foreignKey:AddrOrderID;references:AddrOrderID" json:"userAddrOrder"` // 一对一关系
}

func (o *TzOrder) TableName() string {
	return "tz_order"
}

// TzOrderItem 订单项表
type TzOrderItem struct {
	OrderItemID        uint64     `gorm:"primaryKey;autoIncrement;comment:订单项 ID" json:"orderItemId"`
	ShopID             uint64     `gorm:"not null;comment:店铺 id" json:"shopId"`
	OrderNumber        string     `gorm:"type:varchar(50);not null;comment:订单 order_number" json:"orderNumber"`
	ProdID             uint64     `gorm:"not null;comment:产品 ID" json:"prodId"`
	SkuID              uint64     `gorm:"not null;comment:产品 SkuID" json:"skuId"`
	ProdCount          int        `gorm:"not null;default:0;comment:购物车产品个数" json:"prodCount"`
	ProdName           string     `gorm:"type:varchar(120);not null;default:'';comment:产品名称" json:"prodName"`
	SkuName            string     `gorm:"type:varchar(120);comment:sku 名称" json:"skuName"`
	Pic                string     `gorm:"type:varchar(255);not null;default:'';comment:产品主图片路径" json:"pic"`
	Price              float64    `gorm:"not null;comment:产品价格" json:"price"`
	UserID             string     `gorm:"type:varchar(36);not null;default:'';comment:用户 Id" json:"userId"`
	ProductTotalAmount float64    `gorm:"not null;comment:商品总金额"  json:"productTotalAmount"`
	RecTime            time.Time  `gorm:"not null;comment:购物时间" json:"recTime"`
	CommSts            int        `gorm:"not null;default:0;comment:评论状态： 0 未评价  1 已评价" json:"commSts"`
	DistributionCardNo string     `gorm:"type:varchar(36);comment:推广员使用的推销卡号" json:"distributionCardNo"`
	BasketDate         *time.Time `gorm:"comment:加入购物车时间" json:"basketDate"`
}

func (o *TzOrderItem) TableName() string {
	return "tz_order_item"
}

// TzUserAddrOrder 地址表
type TzUserAddrOrder struct {
	AddrOrderID uint64    `gorm:"primaryKey;autoIncrement;column:addr_order_id;comment:ID" json:"addrOrderId"`
	AddrID      uint64    `gorm:"column:addr_id;comment:地址ID" json:"addrId" `
	UserID      string    `gorm:"column:user_id;type:varchar(36);not null;comment:用户ID" json:"userId"`
	Receiver    string    `gorm:"column:receiver;type:varchar(50);comment:收货人" json:"receiver"`
	ProvinceID  *uint64   `gorm:"column:province_id;comment:省ID" json:"provinceId"`
	Province    string    `gorm:"column:province;type:varchar(100);comment:省" json:"province"`
	AreaID      *uint64   `gorm:"column:area_id;comment:区域ID" json:"areaId"`
	Area        string    `gorm:"column:area;type:varchar(20);comment:区" json:"area"`
	CityID      *uint64   `gorm:"column:city_id;comment:城市ID" json:"cityId"`
	City        string    `gorm:"column:city;type:varchar(20);comment:城市" json:"city"`
	Addr        string    `gorm:"column:addr;type:varchar(1000);comment:地址" json:"addr"`
	PostCode    string    `gorm:"column:post_code;type:varchar(15);comment:邮编" json:"postCode"`
	Mobile      string    `gorm:"column:mobile;type:varchar(20);comment:手机" json:"mobile"`
	CreateTime  time.Time `gorm:"column:create_time;not null;comment:建立时间" json:"createTime"`
	Version     int       `gorm:"column:version;default:0;comment:版本号" json:"version"`
}

func (o *TzUserAddrOrder) TableName() string {
	return "tz_user_addr_order"
}

// TzDelivery 对应数据库表 tz_delivery 的结构体
type TzDelivery struct {
	DvyId          uint64    `gorm:"primaryKey;autoIncrement;column:dvy_id" json:"dvyId"`
	DvyName        string    `gorm:"column:dvy_name;not null" json:"dvyName"`
	CompanyHomeUrl string    `gorm:"column:company_home_url" json:"companyHomeUrl"`
	RecTime        time.Time `gorm:"column:rec_time;not null" json:"recTime"`
	ModifyTime     time.Time `gorm:"column:modify_time;not null" json:"modifyTime"`
	QueryUrl       string    `gorm:"column:query_url;not null" json:"queryUrl"`
}

func (o *TzDelivery) TableName() string {
	return "tz_delivery"

}

// TzPickAddr 对应数据库表 tz_pick_addr 的结构体
type TzPickAddr struct {
	AddrID     uint64 `gorm:"primaryKey;autoIncrement;column:addr_id;comment:ID" json:"addrId"`
	AddrName   string `gorm:"column:addr_name;type:varchar(36);comment:自提点名称" json:"addrName"`
	Addr       string `gorm:"column:addr;type:varchar(1000);comment:地址" json:"addr"`
	Mobile     string `gorm:"column:mobile;type:varchar(20);comment:手机" json:"mobile"`
	ProvinceID uint64 `gorm:"column:province_id;comment:省份ID" json:"provinceId"`
	Province   string `gorm:"column:province;type:varchar(32);comment:省份" json:"province"`
	CityID     uint64 `gorm:"column:city_id;comment:城市ID" json:"cityId"`
	City       string `gorm:"column:city;type:varchar(32);comment:城市" json:"city"`
	AreaID     uint64 `gorm:"column:area_id;comment:区/县ID" json:"areaId"`
	Area       string `gorm:"column:area;type:varchar(32);comment:区/县" json:"area"`
	ShopID     uint64 `gorm:"column:shop_id;comment:店铺id" json:"shopId"`
}

// TzUser 对应数据库表tz_user的结构体，部分字段调整为可为空
type TzUser struct {
	UserId        string     `gorm:"type:varchar(36);not null;default:'';primaryKey;comment:'ID'" json:"userId"`
	NickName      *string    `gorm:"type:varchar(50);comment:'用户昵称'" json:"nickName"`
	RealName      *string    `gorm:"type:varchar(50);comment:'真实姓名'" json:"realName"`
	UserMail      *string    `gorm:"type:varchar(100);comment:'用户邮箱';unique" json:"userMail"`
	LoginPassword *string    `gorm:"type:varchar(255);comment:'登录密码'" json:"loginPassword"`
	PayPassword   *string    `gorm:"type:varchar(50);comment:'支付密码'" json:"payPassword"`
	UserMobile    *string    `gorm:"type:varchar(50);comment:'手机号码';unique" json:"userMobile"`
	ModifyTime    time.Time  `gorm:"type:datetime;comment:'修改时间'" json:"modifyTime"`
	UserRegtime   time.Time  `gorm:"type:datetime;not null;comment:'注册时间'" json:"userRegtime"`
	UserRegip     *string    `gorm:"type:varchar(50);comment:'注册IP'" json:"userRegip"`
	UserLasttime  *time.Time `gorm:"type:datetime;comment:'最后登录时间'" json:"userLasttime"`
	UserLastip    *string    `gorm:"type:varchar(50);comment:'最后登录IP'" json:"userLastip"`
	UserMemo      *string    `gorm:"type:varchar(500);comment:'备注'" json:"userMemo"`
	Sex           *string    `gorm:"type:char(1);default:'M';comment:'M(男) or F(女)'" json:"sex"`
	BirthDate     *string    `gorm:"type:char(10);comment:'例如：2009-11-27'" json:"birthDate"`
	Pic           *string    `gorm:"type:varchar(255);comment:'头像图片路径'" json:"pic"`
	Status        *int       `gorm:"type:int;not null;default:1;comment:'状态 1 正常 0 无效'" json:"status"`
	Score         *int       `gorm:"type:int;comment:'用户积分'" json:"score"`
}

func (TzUser) TableName() string {
	return "tz_user"
}

// TzHotSearch 对应数据库表 tz_hot_search 的结构体
type TzHotSearch struct {
	HotSearchId uint64     `gorm:"column:hot_search_id;primaryKey;autoIncrement" json:"hotSearchId"`
	ShopId      int64      `gorm:"column:shop_id" json:"shopId"`
	Content     string     `gorm:"column:content" json:"content"`
	RecDate     *time.Time `gorm:"column:rec_date" json:"recDate" `
	Seq         *int       `gorm:"column:seq" json:"seq"`
	Status      int8       `gorm:"column:status;default:1" json:"status"`
	Title       string     `gorm:"column:title" json:"title"`
}

// TableName 实现 gorm 的 TableName 接口，用于指定对应的数据库表名
func (TzHotSearch) TableName() string {
	return "tz_hot_search"
}

// TzCategory 对应数据库表 tz_category 的结构体
type TzCategory struct {
	CategoryID   uint64     `gorm:"column:category_id;primaryKey;autoIncrement" json:"categoryId"`
	ShopID       int64      `gorm:"column:shop_id" json:"shopId"`
	ParentID     uint64     `gorm:"column:parent_id" json:"parentId"`
	CategoryName string     `gorm:"column:category_name" json:"categoryName"`
	Icon         string     `gorm:"column:icon" json:"icon"`
	Pic          string     `gorm:"column:pic" json:"pic"`
	Seq          int        `gorm:"column:seq" json:"seq"`
	Status       int        `gorm:"column:status" json:"status"`
	RecTime      *time.Time `gorm:"column:rec_time" json:"recTime"`
	Grade        int        `gorm:"column:grade" json:"grade"`
	UpdateTime   *time.Time `gorm:"column:update_time" json:"updateTime"`
}

func (TzCategory) TableName() string {
	return "tz_category"
}

// TzNotice 对应数据库表 tz_notice 的结构体
type TzNotice struct {
	ID          int64      `gorm:"primaryKey;autoIncrement;comment:'公告id'" json:"id"`
	ShopId      *int64     `gorm:"type:bigint;comment:'店铺id'" json:"shopId"`
	Title       *string    `gorm:"type:varchar(36);comment:'公告标题'" json:"title"`
	Content     string     `gorm:"type:text;comment:'公告内容'" json:"content"`
	Status      *int8      `gorm:"type:tinyint(1);comment:'状态(1:公布 0:撤回)'" json:"status"`
	IsTop       *int8      `gorm:"type:tinyint;comment:'是否置顶'" json:"isTop"`
	PublishTime *time.Time `gorm:"type:timestamp;comment:'发布时间'" json:"publishTime"`
	UpdateTime  *time.Time `gorm:"type:timestamp;null;default:CURRENT_TIMESTAMP;comment:'更新时间'" json:"updateTime"`
}

func (TzNotice) TableName() string {
	return "tz_notice"
}

// TzProdTag 对应数据库中的tz_prod_tag表的实体结构体
type TzProdTag struct {
	ID         int64      `gorm:"primaryKey;autoIncrement;comment:'分组标签id'"`
	Title      *string    `gorm:"type:varchar(36);comment:'分组标题'"`
	ShopId     *int64     `gorm:"type:bigint;comment:'店铺Id'"`
	Status     *int8      `gorm:"type:tinyint(1);comment:'状态(1为正常,0为删除)'"`
	IsDefault  *int8      `gorm:"type:tinyint(1);comment:'默认类型(0:商家自定义,1:系统默认)'"`
	ProdCount  *int64     `gorm:"type:bigint;comment:'商品数量'"`
	Style      *int       `gorm:"type:int;comment:'列表样式(0:一列一个,1:一列两个,2:一列三个)'"`
	Seq        *int       `gorm:"type:int;comment:'排序'"`
	CreateTime *time.Time `gorm:"type:timestamp;comment:'创建时间'"`
	UpdateTime *time.Time `gorm:"type:timestamp;comment:'修改时间'"`
	DeleteTime *time.Time `gorm:"type:timestamp;comment:'删除时间'"`
}

// TzIndexImg 对应数据库中的tz_index_img表的实体结构体
type TzIndexImg struct {
	ImgId      uint64     `gorm:"column:img_id;primaryKey;autoIncrement" json:"imgId"`
	ShopId     int64      `gorm:"column:shop_id" json:"shopId"`
	ImgUrl     string     `gorm:"column:img_url" json:"imgUrl"`
	Des        string     `gorm:"column:des" json:"des"`
	Title      string     `gorm:"column:title" json:"title"`
	Link       string     `gorm:"column:link" json:"link"`
	Status     int8       `gorm:"column:status" json:"status"`
	Seq        int        `gorm:"column:seq" json:"seq"`
	UploadTime *time.Time `gorm:"column:upload_time" json:"uploadTime"`
	Relation   int64      `gorm:"column:relation" json:"relation"`
	Type       int        `gorm:"column:type" json:"type"`
}

// TzProd 对应 tz_prod 表的实体结构体
type TzProd struct {
	ProdID             *uint64        `gorm:"column:prod_id;primaryKey;autoIncrement" json:"prodId"`
	ProdName           *string        `gorm:"column:prod_name;type:varchar(300);not null;default:''" json:"prodName"`
	ShopID             *int64         `gorm:"column:shop_id" json:"shopId"`
	OriPrice           *float64       `gorm:"column:ori_price;type:decimal(15,2);default:0.00" json:"oriPrice"`
	Price              *float64       `gorm:"column:price;type:decimal(15,2)" json:"price"`
	Brief              *string        `gorm:"column:brief;type:varchar(500);default:''" json:"brief"`
	Content            *string        `gorm:"column:content;type:text" json:"content"`
	Pic                *string        `gorm:"column:pic;type:varchar(255)" json:"pic"`
	Imgs               *string        `gorm:"column:imgs;type:varchar(1000)" json:"imgs"`
	Status             *int           `gorm:"column:status;default:0" json:"status"`
	CategoryID         *uint64        `gorm:"column:category_id" json:"categoryId"`
	SoldNum            *int           `gorm:"column:sold_num" json:"soldNum"`
	TotalStocks        *int           `gorm:"column:total_stocks;default:0" json:"totalStocks"`
	DeliveryMode       sql.NullString `gorm:"column:delivery_mode;type:json" json:"deliveryMode"`
	DeliveryTemplateID *int64         `gorm:"column:delivery_template_id" json:"deliveryTemplateId"`
	CreateTime         *time.Time     `gorm:"column:create_time" json:"createTime"`
	UpdateTime         *time.Time     `gorm:"column:update_time" json:"updateTime"`
	PutawayTime        *time.Time     `gorm:"column:putaway_time" json:"putawayTime"`
	Version            *int           `gorm:"column:version" json:"version"`
}

// TableName 返回该结构体对应的数据库表名
func (TzProd) TableName() string {
	return "tz_prod"
}

// TzSku 对应 tz_sku 表的实体结构体
type TzSku struct {
	SkuID        *uint64    `gorm:"column:sku_id;primaryKey;autoIncrement" json:"skuId"`
	ProdID       *uint64    `gorm:"column:prod_id;not null" json:"prodId"`
	Properties   *string    `gorm:"column:properties;type:varchar(2000);default:''" json:"properties"`
	OriPrice     *float64   `gorm:"column:ori_price;type:decimal(15,2)" json:"oriPrice"`
	Price        *float64   `gorm:"column:price;type:decimal(15,2)" json:"price"`
	Stocks       *int       `gorm:"column:stocks;not null" json:"stocks"`
	ActualStocks *int       `gorm:"column:actual_stocks" json:"actualStocks"`
	UpdateTime   *time.Time `gorm:"column:update_time;not null" json:"updateTime"`
	RecTime      *time.Time `gorm:"column:rec_time;not null" json:"recTime"`
	PartyCode    *string    `gorm:"column:party_code;type:varchar(100)" json:"partyCode"`
	ModelID      *string    `gorm:"column:model_id;type:varchar(100)" json:"modelId"`
	Pic          *string    `gorm:"column:pic;type:varchar(500)" json:"pic"`
	SkuName      *string    `gorm:"column:sku_name;type:varchar(120)" json:"skuName"`
	ProdName     *string    `gorm:"column:prod_name;type:varchar(255)" json:"prodName"`
	Version      *int       `gorm:"column:version;not null;default:0" json:"version"`
	Weight       *float64   `gorm:"column:weight" json:"weight"`
	Volume       *float64   `gorm:"column:volume" json:"volume"`
	Status       *int       `gorm:"column:status;default:1" json:"status"`
	IsDelete     *int       `gorm:"column:is_delete" json:"isDelete"`
}

// TableName 实现gorm的TableName方法，用于指定该结构体对应的数据库表名
func (TzSku) TableName() string {
	return "tz_sku"
}

// TzShopDetail 对应 tz_shop_detail
type TzShopDetail struct {
	ShopID           int64     `gorm:"column:shop_id;primaryKey;autoIncrement"`
	ShopName         string    `gorm:"column:shop_name"`
	UserID           string    `gorm:"column:user_id;unique"`
	ShopType         *int8     `gorm:"column:shop_type"`
	Intro            string    `gorm:"column:intro"`
	ShopNotice       string    `gorm:"column:shop_notice"`
	ShopIndustry     *int8     `gorm:"column:shop_industry"`
	ShopOwner        string    `gorm:"column:shop_owner"`
	Mobile           string    `gorm:"column:mobile;unique"`
	Tel              string    `gorm:"column:tel"`
	ShopLat          string    `gorm:"column:shop_lat"`
	ShopLng          string    `gorm:"column:shop_lng"`
	ShopAddress      string    `gorm:"column:shop_address"`
	Province         string    `gorm:"column:province"`
	City             string    `gorm:"column:city"`
	Area             string    `gorm:"column:area"`
	PcaCode          string    `gorm:"column:pca_code"`
	ShopLogo         string    `gorm:"column:shop_logo"`
	ShopPhotos       string    `gorm:"column:shop_photos"`
	OpenTime         string    `gorm:"column:open_time"`
	ShopStatus       *int8     `gorm:"column:shop_status"`
	TransportType    *int8     `gorm:"column:transport_type"`
	FixedFreight     float64   `gorm:"column:fixed_freight"`
	FullFreeShipping float64   `gorm:"column:full_free_shipping"`
	CreateTime       time.Time `gorm:"column:create_time"`
	UpdateTime       time.Time `gorm:"column:update_time"`
	IsDistribution   *int8     `gorm:"column:is_distribution"`
}

func (TzShopDetail) TableName() string {
	return "tz_shop_detail"
}

// TzTransport 对应数据库表 tz_transport 的结构体
type TzTransport struct {
	TransportID      int64     `gorm:"primaryKey;autoIncrement;column:transport_id;comment:运费模板id" json:"transportId"`
	TransName        string    `gorm:"column:trans_name;type:varchar(36);comment:运费模板名称" json:"transName"`
	CreateTime       time.Time `gorm:"column:create_time;type:datetime;comment:创建时间" json:"createTime"`
	ShopID           int64     `gorm:"column:shop_id;type:bigint(20);comment:店铺id" json:"shopId"`
	ChargeType       int8      `gorm:"column:charge_type;type:tinyint(2);comment:收费方式（0 按件数,1 按重量 2 按体积）" json:"chargeType"`
	IsFreeFee        int8      `gorm:"column:is_free_fee;type:tinyint(2);comment:是否包邮 0:不包邮 1:包邮" json:"isFreeFee"`
	HasFreeCondition int8      `gorm:"column:has_free_condition;type:tinyint(2);comment:是否含有包邮条件 0 否 1是" json:"hasFreeCondition"`

	// 运费项
	Transfees []TzTransfee `gorm:"foreignKey:TransportID" json:"transfees"`

	// 指定条件包邮项
	TransfeeFrees []TzTransfeeFree `gorm:"foreignKey:TransportID" json:"transfeeFrees"`
}

// TzTransfee 对应数据库表 tz_transfee 的结构体
type TzTransfee struct {
	TransfeeID      int64   `gorm:"primaryKey;autoIncrement;column:transfee_id;comment:运费项id" json:"transfeeId"`
	TransportID     int64   `gorm:"column:transport_id;comment:运费模板id" json:"transportId"`
	ContinuousPiece float64 `gorm:"column:continuous_piece;type:decimal(15,2);comment:续件数量" json:"continuousPiece"`
	FirstPiece      float64 `gorm:"column:first_piece;type:decimal(15,2);comment:首件数量" json:"firstPiece"`
	ContinuousFee   float64 `gorm:"column:continuous_fee;type:decimal(15,2);comment:续件费用" json:"continuousFee"`
	FirstFee        float64 `gorm:"column:first_fee;type:decimal(15,2);comment:首件费用" json:"firstFee"`

	// 运费项对应的城市
	Transcities []TzTranscity `gorm:"foreignKey:TransfeeID" json:"cityList"`
}

// TzTranscity 对应数据库表 tz_transcity 的结构体
type TzTranscity struct {
	TranscityID int64 `gorm:"primaryKey;autoIncrement;column:transcity_id;comment:指定条件包邮城市项id"`
	TransfeeID  int64 `gorm:"column:transfee_id;comment:指定条件包邮项id"`
	CityID      int64 `gorm:"column:city_id;comment:城市id"`

	// 城市信息
	TzArea TzArea `gorm:"foreignKey:CityID"`
}

// TzArea 对应数据库表 tz_area 的结构体
type TzArea struct {
	AreaID   int64     `gorm:"primaryKey;column:area_id" json:"areaId"`
	AreaName string    `gorm:"column:area_name;not null" json:"areaName"`
	ParentID int64     `gorm:"column:parent_id;not null" json:"parentId"`
	Level    int       `gorm:"column:level;not null" json:"level"`
	Areas    []*TzArea `gorm:"-" json:"areas"`
}

// TableName 指定表名
func (a TzArea) TableName() string {
	return "tz_area"
}

// TzTransfeeFree 对应数据库表 tz_transfee_free 的结构体
type TzTransfeeFree struct {
	TransfeeFreeID int64   `gorm:"primaryKey;autoIncrement;column:transfee_free_id;comment:指定条件包邮项id"`
	TransportID    int64   `gorm:"column:transport_id;comment:运费模板id"`
	FreeType       int8    `gorm:"column:free_type;type:tinyint(2);comment:包邮方式 （0 满x件/重量/体积包邮 1满金额包邮 2满x件/重量/体积且满金额包邮）"`
	Amount         float64 `gorm:"column:amount;type:decimal(15,2);comment:需满金额"`
	Piece          float64 `gorm:"column:piece;type:decimal(15,2);comment:包邮x件/重量/体积"`

	// 指定条件包邮项对应的城市
	TranscityFrees []TzTranscityFree `gorm:"foreignKey:TransfeeFreeID"`
}

// TzTranscityFree 对应数据库表 tz_transcity_free 的结构体
type TzTranscityFree struct {
	TranscityFreeID int64 `gorm:"primaryKey;autoIncrement;column:transcity_free_id;comment:指定条件包邮城市项id"`
	TransfeeFreeID  int64 `gorm:"column:transfee_free_id;comment:指定条件包邮项id"`
	FreeCityID      int64 `gorm:"column:free_city_id;comment:城市id"`

	// 城市信息
	TzArea TzArea `gorm:"foreignKey:FreeCityID"`
}

// TzProdComm 对应 tz_prod_comm 表的实体类
type TzProdComm struct {
	ProdCommID   uint64    `gorm:"column:prod_comm_id;primaryKey;autoIncrement" json:"prodCommId"`
	ProdID       uint64    `gorm:"column:prod_id" json:"prodId"`
	OrderItemID  uint64    `gorm:"column:order_item_id" json:"orderItemId"`
	UserID       string    `gorm:"column:user_id"  json:"userId"`
	Content      string    `gorm:"column:content" json:"content"`
	ReplyContent string    `gorm:"column:reply_content" json:"replyContent"`
	RecTime      time.Time `gorm:"column:rec_time" json:"recTime"`
	ReplyTime    time.Time `gorm:"column:reply_time" json:"replyTime"`
	ReplySts     int       `gorm:"column:reply_sts" json:"replySts"`
	Postip       string    `gorm:"column:postip" json:"postip"`
	Score        int8      `gorm:"column:score"  json:"score"`
	UsefulCounts int       `gorm:"column:useful_counts" json:"usefulCounts"`
	Pics         string    `gorm:"column:pics"  json:"pics"`
	IsAnonymous  int       `gorm:"column:is_anonymous" json:"isAnonymous"`
	Status       int       `gorm:"column:status" json:"status"`
	Evaluate     int8      `gorm:"column:evaluate" json:"evaluate"`
}

func (a TzProdComm) TableName() string {
	return "tz_prod_comm"
}

// TzUserCollection 对应数据库中的tz_user_collection表
type TzUserCollection struct {
	ID         int64     `gorm:"primaryKey;autoIncrement" json:"id"`
	ProdID     int64     `gorm:"column:prod_id" json:"prod_id"`
	UserID     string    `gorm:"column:user_id;type:varchar(36);charset=utf8mb3" json:"user_id"`
	CreateTime time.Time `gorm:"column:create_time" json:"create_time"`
}

// TableName 返回该结构体对应的数据库表名
func (TzUserCollection) TableName() string {
	return "tz_user_collection"
}

// TZBasket 用于映射数据库表tz_basket
type TZBasket struct {
	BasketId           int64     `gorm:"column:basket_id;primaryKey" json:"basketId"`
	ShopId             int64     `gorm:"column:shop_id" json:"shopId"`
	ProdId             int64     `gorm:"column:prod_id" json:"prodId"`
	SkuId              int64     `gorm:"column:sku_id" json:"skuId"`
	UserId             string    `gorm:"column:user_id" json:"userId"`
	BasketCount        int       `gorm:"column:basket_count" json:"basketCount"`
	BasketDate         time.Time `gorm:"column:basket_date" json:"basketDate"`
	DiscountId         int64     `gorm:"column:discount_id" json:"discountId"`
	DistributionCardNo string    `gorm:"column:distribution_card_no" json:"distributionCardNo"`
}

// TableName 实现gorm的TableName方法，指定该实体类对应的数据库表名
func (TZBasket) TableName() string {
	return "tz_basket"
}

// TzOrderSettlement 对应 tz_order_settlement 表的 Gorm 实体类
type TzOrderSettlement struct {
	SettlementID uint64     `gorm:"column:settlement_id;primaryKey;autoIncrement;comment:支付结算单据ID" json:"settlementId"`
	PayNo        *string    `gorm:"column:pay_no;type:varchar(36);comment:支付单号" json:"payNo"`
	BizPayNo     *string    `gorm:"column:biz_pay_no;type:varchar(255);comment:外部订单流水号" json:"bizPayNo"`
	OrderNumber  *string    `gorm:"column:order_number;type:varchar(36);uniqueIndex;comment:order表中的订单号" json:"orderNumber"`
	PayType      *int       `gorm:"column:pay_type;comment:支付方式 1 微信支付 2 支付宝" json:"payType"`
	PayTypeName  *string    `gorm:"column:pay_type_name;type:varchar(50);comment:支付方式名称" json:"payTypeName"`
	PayAmount    *float64   `gorm:"column:pay_amount;type:decimal(15,2);comment:支付金额" json:"payAmount"`
	IsClearing   *int       `gorm:"column:is_clearing;comment:是否清算 0:否 1:是" json:"isClearing"`
	UserID       *string    `gorm:"column:user_id;type:varchar(36);index;comment:用户ID" json:"userId"`
	CreateTime   time.Time  `gorm:"column:create_time;not null;comment:创建时间" json:"createTime"`
	ClearingTime *time.Time `gorm:"column:clearing_time;comment:清算时间" json:"clearingTime"`
	Version      *int       `gorm:"column:version;comment:版本号" json:"version"`
	PayStatus    *int       `gorm:"column:pay_status;comment:支付状态" json:"payStatus"`
}

// TableName 指定表名
func (TzOrderSettlement) TableName() string {
	return "tz_order_settlement"
}
